package com.cans.lightning.business.lowcode.manager.form.loader.formBean;

import com.cans.lightning.business.lowcode.dto.AppFormDto;
import com.cans.lightning.business.lowcode.manager.form.bean.AppFormBean;
import com.cans.lightning.business.lowcode.manager.form.loader.AbstractBeanLoader;
import com.cans.lightning.business.lowcode.service.api.IAppFormDefinitionService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * formBean 基础信息加载
 *
 * @author cans
 * @date 2023/11/29
 **/
@Component
public class BeanBaseLoader extends AbstractBeanLoader<AppFormBean> {

    @Resource
    private IAppFormDefinitionService formDefinitionService;

    @Override
    public AppFormBean loadOne(AppFormBean appFormBean) {
        AppFormDto appFormDto = formDefinitionService.getDtoById(appFormBean.getId());
        appFormBean.setAppId(appFormDto.getAppId());
        appFormBean.setFormName(appFormDto.getFormName());
        appFormBean.setFieldIndex(appFormDto.getFieldIndex());
        return appFormBean;
    }
}
